#pragma once
#include <future>
#include <vector>

namespace util {
    namespace message{
        enum MessageType{
            AM_PLAYER_STOPPED
        };
        class IMessageHandler{
        public:
            virtual bool Receive(MessageType msg, void * param) = 0;

            // virtual std::future<bool> AsyncReceive(MessageType msg, void * param);
        };

        class IUniqueMessageHandler : protected IMessageHandler{
        public:
            bool SetPtr(IUniqueMessageHandler ** pptr);

            IMessageHandler * Expose();
        private:
            IUniqueMessageHandler ** pptr = nullptr;
        };

        class Event {
        public:
            Event(MessageType msg);

            virtual bool AddListener(IMessageHandler * phandler);

            virtual void Invoke(void * param);
        protected:
            MessageType msg;
            std::vector<IMessageHandler *> handler_list;
        };

        // class AsyncEvent : Event {
        // public:
        //     virtual void Invoke(void * param);
        // protected:
        // };
    }
}